package com.seednia.module.core.profile.dto;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import com.seednia.foundation.framework.dto.AbstractRecord;
import com.seednia.foundation.framework.dto.ICategorizable;
import com.seednia.module.core.category.dto.CategoryDto;
import com.seednia.module.core.user.dto.UserDto;

/**
 * Entity Class com.seednia.module.core.profile.dto.ExperienceDto
 * Generated by hbm2java_entity_class.ftl (v20110614)
 *
 * @author Young Suk Ahn
 */
@XmlRootElement(name = "ExperienceDto", 
		namespace = "http://seednia.com/core/1.0")
@XmlType(name = "ExperienceDto")
@XmlAccessorType(XmlAccessType.FIELD)
public class ExperienceDto extends AbstractRecord implements ICategorizable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5774668755520534862L;
	
	private long profileSid = 0; /* The profile this attribute belongs to  */ 
	private int position = 0; /* The display ordering (within category-profile)  */ 
	private String type = null; /* Professional: Tech, Management; Education: High School, Graduate  */ 
	private Long organizationSid = null; /* visibility  */ 
	private String organizationName = null; /* The institution (e.g. company or University)  */ 
	private String department = null; /* Department of the institution  */ 
	private String title = null; /* Title (e.g. Sr. Engineer) or the Level of Education (if education)  */ 
	private String location = null; /* Location of the   */ 
	private String description = null; /* Description of the experience  */ 
	private String startDate = null; /* The date this record was created  */ 
	private String endDate = null; /* The date this record was created  */ 
	private int currently = 0; /* Currently in the experience (working, studying,etc). 0=false, 1=true  */ 
	private String notes = null; /* Any other notes  */ 

	// Many to one mappings:
	private com.seednia.module.core.user.dto.UserDto creatorDto = null; /* The author of the post  */ 
	private com.seednia.module.core.category.dto.CategoryDto categoryDto = null; /* The category of this object  */ 


	public long getProfileSid() {
		return profileSid;
	}
	public void setProfileSid(long profileSid) {
		//long old = this.profileSid;
        //this.vcs.fireVetoableChange( "profileSid", old, profileSid );
		this.profileSid = profileSid;
        //this.pcs.firePropertyChange( "profileSid", old, profileSid );
	}
	public int getPosition() {
		return position;
	}
	public void setPosition(int position) {
		//int old = this.position;
        //this.vcs.fireVetoableChange( "position", old, position );
		this.position = position;
        //this.pcs.firePropertyChange( "position", old, position );
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public Long getOrganizationSid() {
		return organizationSid;
	}
	public void setOrganizationSid(Long organizationSid) {
		//long old = this.organizationSid;
        //this.vcs.fireVetoableChange( "organizationSid", old, organizationSid );
		this.organizationSid = organizationSid;
        //this.pcs.firePropertyChange( "organizationSid", old, organizationSid );
	}
	public String getOrganizationName() {
		return organizationName;
	}
	public void setOrganizationName(String organization) {
		//String old = this.organization;
        //this.vcs.fireVetoableChange( "organizationName", old, organizationName );
		this.organizationName = organization;
        //this.pcs.firePropertyChange( "organizationName", old, organizationName );
	}
	public String getDepartment() {
		return department;
	}
	public void setDepartment(String department) {
		//String old = this.department;
        //this.vcs.fireVetoableChange( "department", old, department );
		this.department = department;
        //this.pcs.firePropertyChange( "department", old, department );
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		//String old = this.title;
        //this.vcs.fireVetoableChange( "title", old, title );
		this.title = title;
        //this.pcs.firePropertyChange( "title", old, title );
	}
	public String getLocation() {
		return location;
	}
	public void setLocation(String location) {
		//String old = this.location;
        //this.vcs.fireVetoableChange( "location", old, location );
		this.location = location;
        //this.pcs.firePropertyChange( "location", old, location );
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		//String old = this.description;
        //this.vcs.fireVetoableChange( "description", old, description );
		this.description = description;
        //this.pcs.firePropertyChange( "description", old, description );
	}
	public String getStartDate() {
		return startDate;
	}
	public void setStartDate(String startDate) {
		//java.util.Date old = this.startDate;
        //this.vcs.fireVetoableChange( "startDate", old, startDate );
		this.startDate = startDate;
        //this.pcs.firePropertyChange( "startDate", old, startDate );
	}
	public String getEndDate() {
		return endDate;
	}
	public void setEndDate(String endDate) {
		//java.util.Date old = this.endDate;
        //this.vcs.fireVetoableChange( "endDate", old, endDate );
		this.endDate = endDate;
        //this.pcs.firePropertyChange( "endDate", old, endDate );
	}
	public int getCurrently() {
		return currently;
	}
	public void setCurrently(int currently) {
		//int old = this.currenlty;
        //this.vcs.fireVetoableChange( "currently", old, currently );
		this.currently = currently;
        //this.pcs.firePropertyChange( "currently", old, currently );
	}
	public String getNotes() {
		return notes;
	}
	public void setNotes(String notes) {
		//String old = this.notes;
        //this.vcs.fireVetoableChange( "notes", old, notes );
		this.notes = notes;
        //this.pcs.firePropertyChange( "notes", old, notes );
	}


	// Many-to-one mappings:
	public com.seednia.module.core.user.dto.UserDto getCreatorDto() {
		return creatorDto;
	}
	public void setCreatorDto(com.seednia.module.core.user.dto.UserDto creatorDto) {
		//com.seednia.module.core.user.dto.UserDto old = this.creatorDto;
        //super.vcs.fireVetoableChange( "creatorDto", old, creatorDto );
		this.creatorDto = creatorDto;
        //super.pcs.firePropertyChange( "creatorDto", old, creatorDto );
	}
	
	public com.seednia.module.core.category.dto.CategoryDto getCategoryDto() {
		return categoryDto;
	}
	public void setCategoryDto(com.seednia.module.core.category.dto.CategoryDto categoryDto) {
		//com.seednia.module.core.category.dto.CategoryDto old = this.categoryDto;
        //super.vcs.fireVetoableChange( "categoryDto", old, categoryDto );
		this.categoryDto = categoryDto;
        //super.pcs.firePropertyChange( "categoryDto", old, categoryDto );
	}
	
	@Override
	public Long getCreatorSid() {
		return creatorDto != null ? creatorDto.getSid() : null;
	}
	@Override
	public String getCreatorId() {
		return creatorDto != null ? creatorDto.getId() : null;
	}
	public void setCreatorSid(long creatorSid) {
		if (creatorDto == null){
			creatorDto = new UserDto();
		}
		creatorDto.setSid(creatorSid);
	}
	
	// From ICategorizable
	
	@Override
	public Long getCategorySid() {
		return (this.getCategoryDto() != null) ? getCategoryDto().getSid() :  null;
	}
	@Override
	public void setCategorySid(Long categorySid) {
		// This shall only be used by the automatic property loader
		if (this.getCategoryDto() == null){
			categoryDto = new CategoryDto();
		}
		categoryDto.setSid(categorySid);
	}
	@Override
	public String getCategoryName() {
		return (this.getCategoryDto() != null) ? getCategoryDto().getName() :  null;
	}
	@Override
	public void setCategoryName(String categoryName) {
		if (this.getCategoryDto() == null){
			categoryDto = new CategoryDto();
		}
		this.getCategoryDto().setName(categoryName);
	}
	
	/**
	 * To create object from JSONP string
	 * Used by the REST framework when sending this object as parameter
	 * @param jsonStr
	 * @return
	 */
	public static ExperienceDto fromString(String jsonStr) {
		ExperienceDto retval = (ExperienceDto) AbstractRecord.fromString(ExperienceDto.class, jsonStr);
		return retval;
	}
}